package iut.acy.cut4u.ihm;
import iut.acy.cut4u.model.FormatDate;

import javax.swing.JTextField;
import javax.swing.JFormattedTextField;

import java.awt.Color;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import java.text.DateFormat;
import java.text.ParseException;
import java.util.*;


import java.text.* ;
public class JDateField extends JFormattedTextField
{
  
	public JDateField ( )
    { 
     this (FormatDate.format); 
     
     }
   public JDateField (String txt)
   { 
	super (   FormatDate.formatDate );
    
    this.setText(txt);
    this.addFocusListener(new FocusListener() 
	   {   public void 	focusGained(FocusEvent e) 
	       { JDateField jt =(JDateField)e.getSource();
	         if (jt.getText().equals(FormatDate.format ))
	        	 jt.setText(""); 
	         }
           public void	focusLost(FocusEvent e) 
	          {  }
	   });
	 } 
   
    
   public GregorianCalendar getGregorianCalendar( )
   { 
	   return FormatDate.stringToGregorianCalendar(this.getText());
   
   }
}
